<!--文章列表-->
<template>
    <div class="center_center infinite-list" v-infinite-scroll="load" style="overflow: auto"
         infinite-scroll-disabled="busy" infinite-scroll-distance="10">
        <div class="cont_item infinite-list-item" v-for="item in data" :key="item" @click="childEmit(item)">
            <div class="cont_item_title">{{item.articlesTitle}}</div>
            <p class="cont_item_content">用 ％；增益控制范围宽：典2型值可达70dB。{{data}}</p>
            <div class="cont_item_foot">
                <div class="cont_item_foot_1" @click.stop="btn_click" data="电站">点赞</div>
                <div class="cont_item_foot_2" @click.stop="btn_click">阅读(1)</div>
            </div>
        </div>
    </div>
</template>

<script>
    import {defineComponent, ref, onMounted, reactive, getCurrentInstance,} from 'vue'
    import {useRoute, useRouter} from 'vue-router'
    import {ArrowRight} from '@element-plus/icons-vue'
    import axios from "axios";

    export default defineComponent({
        components: {
            ArrowRight
        },
        setup(props, context) {
            const mainjs = getCurrentInstance().appContext.config.globalProperties
            const route = useRoute()
            const router = useRouter()

            let busy = false;
            let count2 = 0;

            let page = 1; //列表页数
            let pageNum = 20; //列表页数

            let list_num = 1; //当前界面的列表中数据
            //界面加载 告诉父类更新面包屑
            onMounted(() => {
                let def = reactive({title: route.name, path: route.path})
                context.emit("MyLifeCycleEmit", JSON.stringify(def))
            })

            let dataList;
            const count = ref(0)
            const data = reactive([])
            let isload = false; //是不是正在请求


            const load = () => {
                busy = true;
                // count2++;
                // data.push({label: "标题122", children: [{label: "标题1-1"}]});
                // console.log(count2 + "奥术大师大所")
                if (!isload) {
                    getList()
                }
                busy = false;
            }
            //跳转
            const childEmit = (item) => {
                context.emit('MyClickEmit', "/Main_View/Article_Info")
            }
            //点击事件
            const btn_click = (event) => {
                console.log(event.target.innerText);
            }
            //获取列表
            const getList = () => {
                // mainjs.$dsd.post('/bkArticles/getList')
                let data = reactive({page: page, pageNum: ""})
                // axios.post('/api/bkArticles/getList', data, "")
                //     .then(res => {
                //         let jsss = res.data
                //         dataList +=  {...jsss}
                //         isload = false
                //         page++;
                //     })
                //     .catch(err => {
                //         debugger
                //         console.log(err);
                //         isload = false;
                //     })
            }

            onMounted(() => {
                getList()
            })
            return {
                data,
                load,
                count,
                busy,
                btn_click,
                getList,
                childEmit
            }
        }
    })

</script>

<style scoped>

</style>